home *** CD-ROM | disk | FTP | other *** search
- !library
-
- '----------------------------------------------------------------------
-
- 'Filename: standard.lib
-
- 'Version: beta 3a ( minor bug fix of beta 3 )
-
- 'Type: ASL Library ( for Quest 2.0/2.1 only )
-
- 'By: A.G. Bampton (originally 10/08/1999)
-
- 'Revision: 21/12/1999
-
- 'Purpose/ See STDLIB.RTF for details of what this library does
- 'Usage: and how to use it.
- '
- 'WARNING: I STRONGLY ADVISE YOU NEVER CHANGE ANY CODE IN THIS
- ' LIBRARY! It's complete and functional 'as is' and if
- ' it has been altered I will not be able to offer any
- ' support for it's use. Tailor/modify the way it works
- ' in external code - either within your 'ASL' game code
- ' or, IF YOU ARE USING QUEST PRO AND CAN COMPILE YOUR
- ' GAME TO A 'CAS' FILE ONLY, by including a customising
- ' library as per 'library_demo.asl' my standard library
- ' demo.
- '----------------------------------------------------------------------
-
- !asl-version <200>
-
- !addto game
- command <look at #object#> do <Look_Proc>
- command <x #object#> do <Look_Proc>
- command <drop #object# in #container#> do <Put_In_Container_Proc>
- command <drop #object# down> do <Drop_Proc>
- command <drop #object#> do <Drop_Proc>
- command <give #give_com_string#> do <Alternate_Give_Proc>
- command <take #object# from #character#> do <Take_Back_Proc>
- command <take #character#'s #object#> do <Take_Back_Proc>
- command <take #character#s #object#> do <Take_Back_Proc>
- command <take #character#' #object#> do <Take_Back_Proc>
- command <take #object#> do <Special_Take_Proc>
- command <customdrop #object# in #container#> do <Put_In_Container_Proc>
- command <customdrop #object#> do <Drop_Proc>
- command <customtake #object# from #character#> do <Take_Back_Proc>
- command <customtake #object#> do <Special_Take_Proc>
- !end
-
-
- !addto synonyms
- examine; inspect = look at
- drop the; put the; put down the; put down; put = drop
- give back the; give back; give the = give
- get the; get; take back the; take back; take the = take
- out of the; out of; back from the; back from; from the = from
- in to; in to the; into the; into; inside the; inside = in
- back to the; back to; to the = to
- !end
-
- '-------------------------------------------------------------------
-
- 'The rest of this library is appended to the calling ASL file
-
-
- define procedure <Alternate_Give_Proc>
- setvar <found_to;0>
- for <to_true;1;$lengthof(#give_com_string#)$> do <to_test>
- if not is <%found_to%;0> then {
- exec <give #give_com_string#;normal>
- setvar <found_to;0>
- }
- else {
- for <space_true;1;$lengthof(#give_com_string#)$> do <space_test>
- setstring <give_char;$left(#give_com_string#;%found_space%)$>
- setstring <give_obj;$mid(#give_com_string#;%found_space%)$>
- exec <give #give_obj# to #give_char#;normal>
- }
- end define
-
-
- define procedure <to_test>
- setstring <to_test_for;$mid(o to c;2;4)$>
- setstring <test_part;$mid(#give_com_string#;%to_true%;4)$>
- if is <#to_test_for#;#test_part#> then setvar <found_to;%to_true%>
- end define
-
-
- define procedure <space_test>
- setstring <to_test_for;$mid(c o;2;1)$>
- setstring <test_part;$mid(#give_com_string#;%space_true%;1)$>
- if is <#to_test_for#;#test_part#> then setvar <found_space;%space_true%>
- end define
-
-
- define procedure <Look_Proc>
-
- if not is <#standard.lib.version#;> then {
-
- if is <$instr(#standard.lib.characters#;#object#)$;0> then {
- setstring <where_it_is;$locationof(#object#)$>
-
- if not is <$instr(#standard.lib.containers#;#where_it_is#)$;0> then {
-
- if not is <$instr(#standard.lib.characters#;#where_it_is#)$;0> then {
-
- if here <#where_it_is#> then {
- moveobject <#object#;#quest.currentroom#>
- showobject <#object#>
- exec <look at #object#;normal>
- moveobject <#object#;#where_it_is#>
- }
- else {
- exec <look at #object#;normal>
- }
-
- }
- else {
-
- if here <#where_it_is#> or got <#where_it_is#> then {
- moveobject <#object#;#quest.currentroom#>
- showobject <#object#>
- exec <look at #object#;normal>
- moveobject <#object#;#where_it_is#>
- }
- else {
- exec <look at #object#;normal>
- }
-
- }
-
- }
- else {
-
- if got <#object#> then {
- moveobject <#object#;#quest.currentroom#>
- showobject <#object#>
- exec <look at #object#;normal>
- do <Check_Contents_Proc>
- hideobject <#object#>
- moveobject <#object#;#where_it_is#>
- }
- else {
- exec <look at #object#;normal>
-
- if here <#object#> then {
- do <Check_Contents_Proc>
- }
-
- }
-
- }
-
- }
- else {
- exec <look at #object#;normal>
-
- if here <#object#> then {
- do <Check_Contents_Proc>
- }
- }
-
- }
- else {
- do <Old_Look_Proc>
- }
-
- end define
-
- define procedure <Check_Contents_Proc>
-
- if not is <$instr(#standard.lib.containers#;#object#)$;0> then {
- setstring <where_we_were;#quest.currentroom#>
- outputoff
- goto <#object#>
- if is <$lengthof(#quest.objects#)$;0> then {
- goto <#where_we_were#>
- outputon
- }
- else {
- setstring <parsed_list;$gettag(#object#;prefix)$ __
- $parse_object_list$>
- goto <#where_we_were#>
- outputon
- msg <#parsed_list#>
- }
- }
- end define
-
- define function <parse_object_list>
- setvar <found_comma;0>
- for <last_comma;1;$lengthof(#quest.formatobjects#)$> {
- do <Last_Comma_Proc>
- }
- if not is <%found_comma%;0> then {
- setvar <remaining;%last_comma%-%found_comma%>
- setvar <remaining;%remaining%-1>
- setvar <found_comma;%found_comma%-1>
- setstring <left_part;$left(#quest.formatobjects#;__
- %found_comma%)$>
- setstring <right_part;$right(#quest.formatobjects#;__
- %remaining%)$>
- setstring <parsed_object_list;#left_part# and #right_part#.>
- }
- if is <%found_comma%;0> then {
- setstring <parsed_object_list;#quest.formatobjects#.>
- }
- return <#parsed_object_list#>
- end define
-
- define procedure <Last_Comma_Proc>
- setstring <test_part;$mid(#quest.formatobjects#;%last_comma%;1)$>
- if is <#test_part#;,> then setvar <found_comma;%last_comma%>
- end define
-
-
- define procedure <Drop_Proc>
-
- if is <$instr(#standard.lib.characters#;#object#)$;0> then {
- do <override_permitted>
- if is <#override#;yes> then {
-
- if got <#object#> then {
- lose <#object#>
- moveobject <#object#;#quest.currentroom#>
- showobject <#object#>
- setvar <custom_message; $lengthof(#std.lib.message.drop#)$>
- if is <%custom_message%; 0> then msg <You drop the #object#.>
- else msg <#std.lib.message.drop#.>
- }
- else {
- setvar <custom_message; $lengthof(#std.lib.message.notcarried#)$>
- if is <%custom_message%; 0> then msg <You're not holding the #object#.>
- else msg <#std.lib.message.notcarried#.>
- }
-
- }
- }
- else msg <Sorry, I don't understand '#quest.originalcommand#'.>
- end define
-
-
- define procedure <Special_Take_Proc>
-
- if not is <#standard.lib.version#;> then {
-
- if is <$instr(#standard.lib.characters#;#object#)$;0> then {
- do <override_permitted>
- if is <#override#;yes> then {
- setstring <where_it_is;$locationof(#object#)$>
- if not is <$instr(#standard.lib.containers#;#where_it_is#)$;0> then {
- if not is <$instr(#standard.lib.characters#;#where_it_is#)$;0> then {
- if here <#where_it_is#> then {
- exec <take #object# from #where_it_is#>
- }
- else exec <take #object#;normal>
- }
- else {
- if here <#where_it_is#> or got <#where_it_is#> then {
- exec <take #object# from #where_it_is#>
- }
- else exec <take #object#;normal>
- }
- }
- else {
- if got <#object#> then {
- setvar <custom_message; $lengthof(#std.lib.message.alreadygot#)$>
- if is <%custom_message%; 0> then {
- msg <You already have it.>
- }
- else {
- msg <#std.lib.message.alreadygot#.>
- }
- }
- else {
- if here <#object#> then {
- exec <take #object#;normal>
- }
- else {
- exec <take #object#;normal>
- }
- }
- }
- }
- }
- else msg <Sorry, I don't understand '#quest.originalcommand#'.>
- }
- else {
- do <Old_Special_Take_Proc>
- }
- end define
-
-
- define procedure <Take_Back_Proc>
-
- if not is <#standard.lib.version#;> then {
-
- if not is <$instr(#standard.lib.containers#;#character#)$;0> then {
- if is <$instr(#standard.lib.characters#;#character#)$;0> then {
- setstring <container;#character#>
- }
- else {
- setstring <container;#object#>
- }
- do <override_permitted>
- if is <#override#;yes> then {
-
- if here <#character#> or got <#container#> then {
- if is <$locationof(#object#)$;#character#> then {
- moveobject <#object#;#quest.currentroom#>
- give <#object#>
- hideobject <#object#>
- setvar <custom_message; $lengthof(#std.lib.message.takefrom#)$>
- if is <%custom_message%; 0> then {
- if is <$gettag(#character#;look)$;character> then {
- msg <You reach out and take the #object# from $capfirst(#character#)$.> }
- else msg <You take the #object# out of the #character#.>
- }
- else msg <#std.lib.message.takefrom#.>
- }
- else {
- setvar <custom_message; $lengthof(#std.lib.message.objnotheld#)$>
- if is <%custom_message%;0> then {
- if is <$gettag(#character#;look)$;character> then {
- msg <You can't do that, $capfirst(#character#)$ doesn't have the #object#.> }
- else msg <You can't do that, the #object# isn't in the #character#.>
- }
- else msg <#std.lib.message.objnotheld#.>
- }
- }
- else {
- setvar <custom_message; $lengthof(#std.lib.message.charnothere#)$>
- if is <%custom_message%; 0> then {
- if is <$gettag(#character#;look)$;character> then {
- msg <You can't do that, $capfirst(#character#)$ isn't here.> }
- else msg <You can't do that, the #character# isn't here.>
- }
- else msg <#std.lib.message.charnothere#.>
- }
-
- }
- }
- else msg <Sorry, I don't understand '#quest.originalcommand#'.>
- }
- else {
- do <Old_Take_Back_Proc>
- }
- end define
-
-
- define procedure <Put_In_Container_Proc>
- do <override_permitted>
- if is <#override#;yes> then {
-
- if is <#object#;#container#> then do <Put_In_Self_Proc>
- else {
- setstring <test_prefix;$gettag(#container#;prefix)$>
- if is <$lengthof(#test_prefix#)$;0> then do <Not_A_Container_Proc>
- else do <Put_In_Container_Verified_Proc>
- }
-
- }
- else msg <Sorry, I don't understand '#quest.originalcommand#'.>
- end define
-
-
- define procedure <Not_A_Container_Proc>
- setvar <custom_message; $lengthof(#std.lib.message.notacontainer#)$>
- if is <%custom_message%; 0> then msg <It's not possible to do that.>
- else msg <#std.library.message.notacontainer#.>
- end define
-
-
- define procedure <Put_In_Self_Proc>
- setvar <custom_message; $lengthof(#std.lib.message.putinself#)$>
- if is <%custom_message%; 0> then msg <That would be some feat if you could manage it!>
- else msg <#std.library.message.putinself#.>
- end define
-
- define procedure <Put_In_Container_Verified_Proc>
- if is <$gettag(#container#;look)$;character> then {
- msg <( assuming you meant "|iGive #object# to $capfirst(#container#)$"|xi. )>
- exec <give #object# to #container#>
- }
- else if is <$gettag(#object#;look)$;character> and here <#object#> then do <Put_Char_In_Obj_Proc>
- else if is <$gettag(#object#;look)$;character> then do <Character_Not_Here_Proc>
- else {
- if got <#object#> and got <#container#> then do <Put_It_In_Proc>
- else {
- if got <#object#> and here <#container#> then do <Put_It_In_Proc>
- else {
- if got <#object#> then do <No_Container_Here_Proc>
- else {
- do <Nothing_To_Put_In_Proc>
- }
- }
- }
- }
- end define
-
-
- define procedure <Put_Char_In_Obj_Proc>
- setvar <custom_message; $lengthof(#std.lib.message.putcharinobj#)$>
- if is <%custom_message%; 0> then msg <You can't do that with $capfirst(#object#)$.>
- else msg <#std.lib.message.putcharinobj#.>
- end define
-
-
- define procedure <No_Container_Here_Proc>
- setvar <custom_message; $lengthof(#std.lib.message.nocontainerhere#)$>
- if is <%custom_message%; 0> then msg <The #container# isn't available for you __
- to put things in at the moment.>
- else msg <#std.library.message.nocontainerhere#.>
- end define
-
-
- define procedure <Character_Not_Here_Proc>
- setvar <custom_message; $lengthof(#std.lib.message.charnothere#)$>
- if is <%custom_message%; 0> then msg <$capfirst(#object#)$ isn't here.>
- else msg <#std.lib.message.charnothere#.>
- end define
-
-
- define procedure <Nothing_To_Put_In_Proc>
- setvar <custom_message; $lengthof(#std.lib.message.nothingtoputin#)$>
- if is <%custom_message%; 0> then msg <You don't appear to be holding the #object#.>
- else msg <#std.lib.message.nothingtoputin#.>
- end define
-
-
- define procedure <Put_It_In_Proc>
- lose <#object#>
- moveobject <#object#;#container#>
- showobject <#object#@#container#>
- setvar <custom_message; $lengthof(#std.lib.message.putincontainer#)$>
- if is <%custom_message%; 0> then msg <You put the #object# into the #container#.>
- else msg <#std.lib.message.putincontainer#.>
- end define
-
-
- define procedure <override_permitted>
- setstring <override;#reset#>
- if is <$left(#quest.command#;6)$;custom> then {
- if is <#std.lib.override#;yes> then {
- setstring <std.lib.override;#reset#>
- setstring <override;yes>
- }
- else {
- setstring <override;#reset#>
- }
- }
- else setstring <override;yes>
- end define
-
- define procedure <standard_lib_setup>
- setstring <reset;>
- setstring <std.lib.message.override;>
- setstring <std.lib.message.drop;>
- setstring <std.lib.message.notcarried;>
- setstring <std.lib.message.alreadygot;>
- setstring <std.lib.message.takefrom;>
- setstring <std.lib.message.objnotheld;>
- setstring <std.lib.message.charnothere;>
- setstring <std.lib.message.nocontainerhere;>
- setstring <std.lib.message.notacontainer;>
- setstring <std.lib.message.putincontainer;>
- setstring <std.lib.message.nothingtoputin;>
- setstring <std.lib.message.putcharinobj;>
- setstring <std.lib.message.putinself;>
- end define
-
-
- '==== Following code included for backward compatibility only ====
-
- define procedure <Old_Look_Proc>
- if got <#object#> then {
- moveobject <#object#;#quest.currentroom#>
- showobject <#object#>
- exec <look at #object#;normal>
- do <Old_Contents_Proc>
- hideobject <#object#>
- }
- else {
- setstring <where_it_is;$locationof(#object#)$>
-
- if here <#where_it_is#> or got <#where_it_is#> then {
- moveobject <#object#;#quest.currentroom#>
- showobject <#object#>
- exec <look at #object#;normal>
- moveobject <#object#;#where_it_is#>
- do <Old_Contents_Proc>
- }
- else {
- exec <look at #object#;normal>
- do <Old_Contents_Proc>
- }
- }
- end define
-
-
- define procedure <Old_Contents_Proc>
- if is <$locationof(#object#)$;#quest.currentroom#> or got <#object#> then {
- setstring <Where_We_Were;#quest.currentroom#>
- outputoff
- goto <#object#>
- if is <$lengthof(#quest.objects#)$;0> then {
- goto <#Where_We_Were#>
- outputon
- }
- else {
- outputon
- msg <$gettag(#object#;prefix)$ #quest.formatobjects#.>
- outputoff
- goto <#Where_We_Were#>
- outputon
- }
- }
- end define
-
- define procedure <Old_Special_Take_Proc>
- do <override_permitted>
- if is <#override#;yes> then {
-
- setstring <where_it_is;$locationof(#object#)$>
- if here <#where_it_is#> or got <#where_it_is#> then exec <take #object# from #where_it_is#>
- else {
- if got <#object#> then {
- setvar <custom_message; $lengthof(#std.lib.message.alreadygot#)$>
- if is <%custom_message%; 0> then msg <You already have it.>
- else msg <#std.lib.message.alreadygot#.>
- }
- else exec <take #object#;normal>
- }
-
- }
- else msg <Sorry, I don't understand '#quest.originalcommand#'.>
- end define
-
-
- define procedure <Old_Take_Back_Proc>
- do <override_permitted>
- if is <#override#;yes> then {
-
- if here <#character#> or got <#character#> then {
- if is <$locationof(#object#)$;#character#> then {
- moveobject <#object#;#quest.currentroom#>
- give <#object#>
- hideobject <#object#>
- setvar <custom_message; $lengthof(#std.lib.message.takefrom#)$>
- if is <%custom_message%; 0> then {
- if is <$gettag(#character#;look)$;character> then {
- msg <You reach out and take the #object# from $capfirst(#character#)$.> }
- else msg <You take the #object# out of the #character#.>
- }
- else msg <#std.lib.message.takefrom#.>
- }
- else {
- setvar <custom_message; $lengthof(#std.lib.message.objnotheld#)$>
- if is <%custom_message%;0> then {
- if is <$gettag(#character#;look)$;character> then {
- msg <You can't do that, $capfirst(#character#)$ doesn't have the #object#.> }
- else msg <You can't do that, the #object# isn't in the #character#.>
- }
- else msg <#std.lib.message.objnotheld#.>
- }
- }
- else {
- setvar <custom_message; $lengthof(#std.lib.message.charnothere#)$>
- if is <%custom_message%; 0> then {
- if is <$gettag(#character#;look)$;character> then {
- msg <You can't do that, $capfirst(#character#)$ isn't here.> }
- else msg <You can't do that, the #character# isn't here.>
- }
- else msg <#std.lib.message.charnothere#.>
- }
-
- }
- else msg <Sorry, I don't understand '#quest.originalcommand#'.>
- end define
-